package com.shopping.service;

import com.shopping.dao.GoodsMapper;
import com.shopping.entity.Goods;
import com.shopping.entity.MiaoshaGoods;
import com.shopping.vo.GoodsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    public List<GoodsVO> listGoodsVO(){
        return goodsMapper.listGoodsVO();
    }

    public GoodsVO getGoodsVOByGoodsId(long goodsId){
        return goodsMapper.getGoodsVOByGoodsId(goodsId);
    }

    public void reductStock(GoodsVO goodsVOByGoodsId) {

        MiaoshaGoods goods=new MiaoshaGoods();
        goods.setGoodsId(goodsVOByGoodsId.getId());
        goodsMapper.reductStock(goods);
    }
}
